// set DataClass property after constructor !
//
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;

using CStock;

using CUtil;
using CTrading;
using CGrid;

namespace CapitalReSources
{
	
	/// <summary>
	/// Summary description for TradeUserControl.
	/// </summary>
	public class TradeControl : System.Windows.Forms.UserControl,ITradeControl, IContextProvider
	{
		#region members

		protected System.Windows.Forms.TabControl tabControl1;
		//		protected DateTime timeStartCalculation;
		//		protected DateTime timeEndCalculation ;

		protected IProgramContext programContext;
		protected System.Collections.ArrayList tradeEvents;
		
		protected System.Windows.Forms.TabPage tradeViewSystem;

		public EForms.EButton buttonChangeTradeFile;
		public EForms.EButton buttonTradeConfiguration;
		public System.Windows.Forms.Label Label3;
		protected EForms.EButton buttonSimulateSilent;
		public EForms.EButton buttonSingleStep;
		protected System.Windows.Forms.TabPage tabPageOptimize;
		public EForms.EButton buttonOptimizeShare;
		//protected EForms.EButton buttonPrognosis;
		protected EForms.EButton buttonPrognosisPortfolio;

		
		protected EForms.EButton buttonPrognosisPortfolioAdvanced;

        DateTime timeExecutionStart;
        DateTime timeExecutionStop;

		
		//protected ActiveListView activeListView;
        protected EForms.EButton buttonPrognosisShareAdvanced;
		public EForms.EButton buttonReset;
		protected System.Windows.Forms.TabPage tabPageShareSimulation;
		//public EForms.EButton buttonPrognosis;
		public EForms.EButton buttonSimulatePortfolio_1_EachShare;
		public EForms.EButton buttonSingleStepPortfolio;
		public EForms.EButton buttonSharePrognosis;
		public EForms.EButton buttonSimulationPortfolio1Reset;
		
		public EForms.EButton buttonSimulateShare;
		public EForms.EButton buttonSimulatePortfolioSilent;
		private EForms.EButton buttonSimulatePortfolio_1_Overall;
		protected EForms.EButton buttonOptimizePortfolio_1_Overall;
		protected EForms.EButton buttonOptimizePortfolio_New;
		private EForms.EButton buttonSimulatePortfolio_1_OverallSilent;
		public EForms.EButton buttonAllPortfoliosSimulate;
		
		protected EForms.EButton buttonOptimizeAllPortfolios;
		
		private EForms.EButton buttonStatisticsShare;
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		protected System.ComponentModel.Container components = null;
		//private CapitalReSources.GridTrade gridTrade;
		private System.Windows.Forms.Panel panelListView;
        private CGrid.GridTrade gridTrade;
		private System.Windows.Forms.LinkLabel linkLabel1;
		private System.Windows.Forms.TabPage tabPageIntraday;
		protected EForms.EButton buttonIntradayTest;
		protected EForms.EButton buttonIntradaySilent;
		private EForms.EButton buttonTradeStatistics;
		private System.Windows.Forms.TextBox textBoxExecutionTime;
		protected System.Windows.Forms.TabPage tabPagePrognosis;
        protected EForms.EButton buttonOptimizePortfolioSilent;
        public EForms.EButton buttonOptimizeShareSilent;
        private GroupBox gbxPortfolio;
        private GroupBox gbxShare;
        private GroupBox gbxPortfolioOptimize;
        private GroupBox gbxExecutionTime;
        private SplitContainer tradeControlSplitContainer;
        private GroupBox gbxShareOptimize;
		

		#endregion

		#region constructor, dispose

		
		public TradeControl()
		{
			try
			{
				MainClass.Instance.TradeControl = this;
				this.programContext = MainClass.Instance.ProgramContext;
			
			}
			catch
			{
				//this occurs in design mode - do nothing
			}
			try
			{
				this.Cursor= System.Windows.Forms.Cursors.WaitCursor;
				InitializeComponent();
				//-----------------------
		
				this.Cursor= System.Windows.Forms.Cursors.Default;
			}
			catch(Exception e)
			{
				Debug.WriteLine("Error loading control " + e.Message);
			}
		}
	
		public bool InitializeShareData()
		{
			try
			{
				tradeEvents = new System.Collections.ArrayList();
				//dataInitialized = false;
				return true;
			
			}
			catch(Exception e)
			{
				System.Diagnostics.Debug.Assert(false,"TradeSystem: Error initializing share data " + e.Message);
				return false;
			}
			
		}
		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#endregion

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.tabControl1 = new System.Windows.Forms.TabControl();
            this.tabPageShareSimulation = new System.Windows.Forms.TabPage();
            this.gbxShare = new System.Windows.Forms.GroupBox();
            this.buttonSimulateSilent = new EForms.EButton();
            this.buttonSimulateShare = new EForms.EButton();
            this.buttonStatisticsShare = new EForms.EButton();
            this.buttonSingleStep = new EForms.EButton();
            this.buttonReset = new EForms.EButton();
            this.gbxPortfolio = new System.Windows.Forms.GroupBox();
            this.buttonSimulatePortfolio_1_OverallSilent = new EForms.EButton();
            this.buttonSimulatePortfolio_1_Overall = new EForms.EButton();
            this.buttonSimulatePortfolioSilent = new EForms.EButton();
            this.buttonSimulatePortfolio_1_EachShare = new EForms.EButton();
            this.buttonAllPortfoliosSimulate = new EForms.EButton();
            this.buttonSingleStepPortfolio = new EForms.EButton();
            this.buttonSimulationPortfolio1Reset = new EForms.EButton();
            this.Label3 = new System.Windows.Forms.Label();
            this.tabPageOptimize = new System.Windows.Forms.TabPage();
            this.gbxExecutionTime = new System.Windows.Forms.GroupBox();
            this.textBoxExecutionTime = new System.Windows.Forms.TextBox();
            this.gbxShareOptimize = new System.Windows.Forms.GroupBox();
            this.buttonOptimizeShare = new EForms.EButton();
            this.buttonOptimizeShareSilent = new EForms.EButton();
            this.gbxPortfolioOptimize = new System.Windows.Forms.GroupBox();
            this.buttonOptimizePortfolio_New = new EForms.EButton();
            this.buttonOptimizePortfolioSilent = new EForms.EButton();
            this.buttonOptimizePortfolio_1_Overall = new EForms.EButton();
            this.buttonOptimizeAllPortfolios = new EForms.EButton();
            this.tradeViewSystem = new System.Windows.Forms.TabPage();
            this.buttonTradeStatistics = new EForms.EButton();
            this.buttonChangeTradeFile = new EForms.EButton();
            this.buttonTradeConfiguration = new EForms.EButton();
            this.tabPageIntraday = new System.Windows.Forms.TabPage();
            this.buttonIntradaySilent = new EForms.EButton();
            this.buttonIntradayTest = new EForms.EButton();
            this.tabPagePrognosis = new System.Windows.Forms.TabPage();
            this.linkLabel1 = new System.Windows.Forms.LinkLabel();
            this.buttonPrognosisShareAdvanced = new EForms.EButton();
            this.buttonPrognosisPortfolioAdvanced = new EForms.EButton();
            this.buttonPrognosisPortfolio = new EForms.EButton();
            this.buttonSharePrognosis = new EForms.EButton();
            this.panelListView = new System.Windows.Forms.Panel();
            this.tradeControlSplitContainer = new System.Windows.Forms.SplitContainer();
            this.gridTrade = new CGrid.GridTrade();
            this.tabControl1.SuspendLayout();
            this.tabPageShareSimulation.SuspendLayout();
            this.gbxShare.SuspendLayout();
            this.gbxPortfolio.SuspendLayout();
            this.tabPageOptimize.SuspendLayout();
            this.gbxExecutionTime.SuspendLayout();
            this.gbxShareOptimize.SuspendLayout();
            this.gbxPortfolioOptimize.SuspendLayout();
            this.tradeViewSystem.SuspendLayout();
            this.tabPageIntraday.SuspendLayout();
            this.tabPagePrognosis.SuspendLayout();
            this.panelListView.SuspendLayout();
            this.tradeControlSplitContainer.Panel1.SuspendLayout();
            this.tradeControlSplitContainer.Panel2.SuspendLayout();
            this.tradeControlSplitContainer.SuspendLayout();
            this.SuspendLayout();
            // 
            // tabControl1
            // 
            this.tabControl1.Controls.Add(this.tabPageShareSimulation);
            this.tabControl1.Controls.Add(this.tabPageOptimize);
            this.tabControl1.Controls.Add(this.tradeViewSystem);
            this.tabControl1.Controls.Add(this.tabPageIntraday);
            this.tabControl1.Controls.Add(this.tabPagePrognosis);
            this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tabControl1.Location = new System.Drawing.Point(0, 0);
            this.tabControl1.Name = "tabControl1";
            this.tabControl1.SelectedIndex = 0;
            this.tabControl1.Size = new System.Drawing.Size(1040, 188);
            this.tabControl1.TabIndex = 1;
            // 
            // tabPageShareSimulation
            // 
            this.tabPageShareSimulation.Controls.Add(this.gbxShare);
            this.tabPageShareSimulation.Controls.Add(this.gbxPortfolio);
            this.tabPageShareSimulation.Controls.Add(this.Label3);
            this.tabPageShareSimulation.Location = new System.Drawing.Point(4, 22);
            this.tabPageShareSimulation.Name = "tabPageShareSimulation";
            this.tabPageShareSimulation.Size = new System.Drawing.Size(1032, 162);
            this.tabPageShareSimulation.TabIndex = 0;
            this.tabPageShareSimulation.Text = "Trade Simulation";
            // 
            // gbxShare
            // 
            this.gbxShare.Controls.Add(this.buttonSimulateSilent);
            this.gbxShare.Controls.Add(this.buttonSimulateShare);
            this.gbxShare.Controls.Add(this.buttonStatisticsShare);
            this.gbxShare.Controls.Add(this.buttonSingleStep);
            this.gbxShare.Controls.Add(this.buttonReset);
            this.gbxShare.Location = new System.Drawing.Point(3, 6);
            this.gbxShare.Name = "gbxShare";
            this.gbxShare.Size = new System.Drawing.Size(245, 139);
            this.gbxShare.TabIndex = 77;
            this.gbxShare.TabStop = false;
            this.gbxShare.Text = "Share";
            // 
            // buttonSimulateSilent
            // 
            this.buttonSimulateSilent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonSimulateSilent.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonSimulateSilent.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonSimulateSilent.Location = new System.Drawing.Point(6, 19);
            this.buttonSimulateSilent.Name = "buttonSimulateSilent";
            this.buttonSimulateSilent.Size = new System.Drawing.Size(110, 24);
            this.buttonSimulateSilent.TabIndex = 63;
            this.buttonSimulateSilent.Text = "Simulate silent";
            this.buttonSimulateSilent.Click += new System.EventHandler(this.buttonSimulateSilent_Click);
            // 
            // buttonSimulateShare
            // 
            this.buttonSimulateShare.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonSimulateShare.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonSimulateShare.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonSimulateShare.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonSimulateShare.Location = new System.Drawing.Point(6, 49);
            this.buttonSimulateShare.Name = "buttonSimulateShare";
            this.buttonSimulateShare.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonSimulateShare.Size = new System.Drawing.Size(110, 24);
            this.buttonSimulateShare.TabIndex = 68;
            this.buttonSimulateShare.Text = "Simulate";
            this.buttonSimulateShare.Click += new System.EventHandler(this.buttonSimulateShare_Click);
            // 
            // buttonStatisticsShare
            // 
            this.buttonStatisticsShare.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonStatisticsShare.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonStatisticsShare.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonStatisticsShare.Location = new System.Drawing.Point(122, 79);
            this.buttonStatisticsShare.Name = "buttonStatisticsShare";
            this.buttonStatisticsShare.Size = new System.Drawing.Size(110, 24);
            this.buttonStatisticsShare.TabIndex = 75;
            this.buttonStatisticsShare.Text = "Statistics";
            this.buttonStatisticsShare.Click += new System.EventHandler(this.buttonStatisticsShare_Click);
            // 
            // buttonSingleStep
            // 
            this.buttonSingleStep.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonSingleStep.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonSingleStep.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonSingleStep.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonSingleStep.Location = new System.Drawing.Point(122, 49);
            this.buttonSingleStep.Name = "buttonSingleStep";
            this.buttonSingleStep.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonSingleStep.Size = new System.Drawing.Size(110, 24);
            this.buttonSingleStep.TabIndex = 55;
            this.buttonSingleStep.Text = "&Single Step";
            this.buttonSingleStep.Click += new System.EventHandler(this.buttonSingleStep_Click);
            // 
            // buttonReset
            // 
            this.buttonReset.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonReset.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonReset.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonReset.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonReset.Location = new System.Drawing.Point(122, 19);
            this.buttonReset.Name = "buttonReset";
            this.buttonReset.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonReset.Size = new System.Drawing.Size(110, 24);
            this.buttonReset.TabIndex = 64;
            this.buttonReset.Text = "&Reset";
            this.buttonReset.Click += new System.EventHandler(this.buttonReset_Click);
            // 
            // gbxPortfolio
            // 
            this.gbxPortfolio.Controls.Add(this.buttonSimulatePortfolio_1_OverallSilent);
            this.gbxPortfolio.Controls.Add(this.buttonSimulatePortfolio_1_Overall);
            this.gbxPortfolio.Controls.Add(this.buttonSimulatePortfolioSilent);
            this.gbxPortfolio.Controls.Add(this.buttonSimulatePortfolio_1_EachShare);
            this.gbxPortfolio.Controls.Add(this.buttonAllPortfoliosSimulate);
            this.gbxPortfolio.Controls.Add(this.buttonSingleStepPortfolio);
            this.gbxPortfolio.Controls.Add(this.buttonSimulationPortfolio1Reset);
            this.gbxPortfolio.Location = new System.Drawing.Point(254, 6);
            this.gbxPortfolio.Name = "gbxPortfolio";
            this.gbxPortfolio.Size = new System.Drawing.Size(357, 142);
            this.gbxPortfolio.TabIndex = 76;
            this.gbxPortfolio.TabStop = false;
            this.gbxPortfolio.Text = "Portfolio";
            // 
            // buttonSimulatePortfolio_1_OverallSilent
            // 
            this.buttonSimulatePortfolio_1_OverallSilent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonSimulatePortfolio_1_OverallSilent.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonSimulatePortfolio_1_OverallSilent.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonSimulatePortfolio_1_OverallSilent.Location = new System.Drawing.Point(6, 49);
            this.buttonSimulatePortfolio_1_OverallSilent.Name = "buttonSimulatePortfolio_1_OverallSilent";
            this.buttonSimulatePortfolio_1_OverallSilent.Size = new System.Drawing.Size(110, 24);
            this.buttonSimulatePortfolio_1_OverallSilent.TabIndex = 73;
            this.buttonSimulatePortfolio_1_OverallSilent.Text = "Simulate silent";
            this.buttonSimulatePortfolio_1_OverallSilent.Click += new System.EventHandler(this.buttonSimulatePortfolio_1_OverallSilent_Click);
            // 
            // buttonSimulatePortfolio_1_Overall
            // 
            this.buttonSimulatePortfolio_1_Overall.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonSimulatePortfolio_1_Overall.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonSimulatePortfolio_1_Overall.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonSimulatePortfolio_1_Overall.Location = new System.Drawing.Point(6, 19);
            this.buttonSimulatePortfolio_1_Overall.Name = "buttonSimulatePortfolio_1_Overall";
            this.buttonSimulatePortfolio_1_Overall.Size = new System.Drawing.Size(110, 24);
            this.buttonSimulatePortfolio_1_Overall.TabIndex = 72;
            this.buttonSimulatePortfolio_1_Overall.Text = "Simulate";
            this.buttonSimulatePortfolio_1_Overall.Click += new System.EventHandler(this.buttonSimulatePortfolio_1_Overall_Click);
            // 
            // buttonSimulatePortfolioSilent
            // 
            this.buttonSimulatePortfolioSilent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonSimulatePortfolioSilent.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonSimulatePortfolioSilent.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonSimulatePortfolioSilent.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonSimulatePortfolioSilent.Location = new System.Drawing.Point(6, 79);
            this.buttonSimulatePortfolioSilent.Name = "buttonSimulatePortfolioSilent";
            this.buttonSimulatePortfolioSilent.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonSimulatePortfolioSilent.Size = new System.Drawing.Size(226, 24);
            this.buttonSimulatePortfolioSilent.TabIndex = 71;
            this.buttonSimulatePortfolioSilent.Text = "Simulate Silent each share indiv.";
            this.buttonSimulatePortfolioSilent.Click += new System.EventHandler(this.buttonSimulatePortfolioSilent_Click);
            // 
            // buttonSimulatePortfolio_1_EachShare
            // 
            this.buttonSimulatePortfolio_1_EachShare.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonSimulatePortfolio_1_EachShare.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonSimulatePortfolio_1_EachShare.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonSimulatePortfolio_1_EachShare.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonSimulatePortfolio_1_EachShare.Location = new System.Drawing.Point(6, 109);
            this.buttonSimulatePortfolio_1_EachShare.Name = "buttonSimulatePortfolio_1_EachShare";
            this.buttonSimulatePortfolio_1_EachShare.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonSimulatePortfolio_1_EachShare.Size = new System.Drawing.Size(342, 24);
            this.buttonSimulatePortfolio_1_EachShare.TabIndex = 65;
            this.buttonSimulatePortfolio_1_EachShare.Text = "Simulate 1 - each share individually";
            this.buttonSimulatePortfolio_1_EachShare.Click += new System.EventHandler(this.buttonSimulatePortfolio_1_EachShare_Click);
            // 
            // buttonAllPortfoliosSimulate
            // 
            this.buttonAllPortfoliosSimulate.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonAllPortfoliosSimulate.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonAllPortfoliosSimulate.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonAllPortfoliosSimulate.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonAllPortfoliosSimulate.Location = new System.Drawing.Point(122, 19);
            this.buttonAllPortfoliosSimulate.Name = "buttonAllPortfoliosSimulate";
            this.buttonAllPortfoliosSimulate.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonAllPortfoliosSimulate.Size = new System.Drawing.Size(110, 24);
            this.buttonAllPortfoliosSimulate.TabIndex = 74;
            this.buttonAllPortfoliosSimulate.Text = "Simulate All";
            this.buttonAllPortfoliosSimulate.Click += new System.EventHandler(this.buttonAllPortfoliosSimulate_Click);
            // 
            // buttonSingleStepPortfolio
            // 
            this.buttonSingleStepPortfolio.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonSingleStepPortfolio.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonSingleStepPortfolio.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonSingleStepPortfolio.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonSingleStepPortfolio.Location = new System.Drawing.Point(122, 49);
            this.buttonSingleStepPortfolio.Name = "buttonSingleStepPortfolio";
            this.buttonSingleStepPortfolio.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonSingleStepPortfolio.Size = new System.Drawing.Size(110, 24);
            this.buttonSingleStepPortfolio.TabIndex = 66;
            this.buttonSingleStepPortfolio.Text = "&Single Step";
            this.buttonSingleStepPortfolio.Click += new System.EventHandler(this.buttonSingleStepPortfolio_Click);
            // 
            // buttonSimulationPortfolio1Reset
            // 
            this.buttonSimulationPortfolio1Reset.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonSimulationPortfolio1Reset.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonSimulationPortfolio1Reset.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonSimulationPortfolio1Reset.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonSimulationPortfolio1Reset.Location = new System.Drawing.Point(238, 19);
            this.buttonSimulationPortfolio1Reset.Name = "buttonSimulationPortfolio1Reset";
            this.buttonSimulationPortfolio1Reset.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonSimulationPortfolio1Reset.Size = new System.Drawing.Size(110, 24);
            this.buttonSimulationPortfolio1Reset.TabIndex = 67;
            this.buttonSimulationPortfolio1Reset.Text = "&Reset";
            this.buttonSimulationPortfolio1Reset.Click += new System.EventHandler(this.buttonSimulationPortfolio1Reset_Click);
            // 
            // Label3
            // 
            this.Label3.BackColor = System.Drawing.SystemColors.Control;
            this.Label3.Cursor = System.Windows.Forms.Cursors.Default;
            this.Label3.ForeColor = System.Drawing.SystemColors.ControlText;
            this.Label3.Location = new System.Drawing.Point(128, 472);
            this.Label3.Name = "Label3";
            this.Label3.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.Label3.Size = new System.Drawing.Size(65, 17);
            this.Label3.TabIndex = 23;
            // 
            // tabPageOptimize
            // 
            this.tabPageOptimize.Controls.Add(this.gbxExecutionTime);
            this.tabPageOptimize.Controls.Add(this.gbxShareOptimize);
            this.tabPageOptimize.Controls.Add(this.gbxPortfolioOptimize);
            this.tabPageOptimize.Location = new System.Drawing.Point(4, 22);
            this.tabPageOptimize.Name = "tabPageOptimize";
            this.tabPageOptimize.Size = new System.Drawing.Size(1032, 185);
            this.tabPageOptimize.TabIndex = 4;
            this.tabPageOptimize.Text = "Optimize";
            // 
            // gbxExecutionTime
            // 
            this.gbxExecutionTime.Controls.Add(this.textBoxExecutionTime);
            this.gbxExecutionTime.Location = new System.Drawing.Point(388, 3);
            this.gbxExecutionTime.Name = "gbxExecutionTime";
            this.gbxExecutionTime.Size = new System.Drawing.Size(135, 51);
            this.gbxExecutionTime.TabIndex = 73;
            this.gbxExecutionTime.TabStop = false;
            this.gbxExecutionTime.Text = "Execution time";
            // 
            // textBoxExecutionTime
            // 
            this.textBoxExecutionTime.Location = new System.Drawing.Point(6, 19);
            this.textBoxExecutionTime.Name = "textBoxExecutionTime";
            this.textBoxExecutionTime.Size = new System.Drawing.Size(123, 20);
            this.textBoxExecutionTime.TabIndex = 67;
            // 
            // gbxShareOptimize
            // 
            this.gbxShareOptimize.Controls.Add(this.buttonOptimizeShare);
            this.gbxShareOptimize.Controls.Add(this.buttonOptimizeShareSilent);
            this.gbxShareOptimize.Location = new System.Drawing.Point(3, 3);
            this.gbxShareOptimize.Name = "gbxShareOptimize";
            this.gbxShareOptimize.Size = new System.Drawing.Size(130, 155);
            this.gbxShareOptimize.TabIndex = 72;
            this.gbxShareOptimize.TabStop = false;
            this.gbxShareOptimize.Text = "Share";
            // 
            // buttonOptimizeShare
            // 
            this.buttonOptimizeShare.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonOptimizeShare.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonOptimizeShare.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonOptimizeShare.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonOptimizeShare.Location = new System.Drawing.Point(7, 19);
            this.buttonOptimizeShare.Name = "buttonOptimizeShare";
            this.buttonOptimizeShare.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonOptimizeShare.Size = new System.Drawing.Size(110, 24);
            this.buttonOptimizeShare.TabIndex = 56;
            this.buttonOptimizeShare.Text = "Optimize";
            this.buttonOptimizeShare.Click += new System.EventHandler(this.buttonOptimizeShare_Click);
            // 
            // buttonOptimizeShareSilent
            // 
            this.buttonOptimizeShareSilent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonOptimizeShareSilent.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonOptimizeShareSilent.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonOptimizeShareSilent.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonOptimizeShareSilent.Location = new System.Drawing.Point(7, 46);
            this.buttonOptimizeShareSilent.Name = "buttonOptimizeShareSilent";
            this.buttonOptimizeShareSilent.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonOptimizeShareSilent.Size = new System.Drawing.Size(110, 24);
            this.buttonOptimizeShareSilent.TabIndex = 70;
            this.buttonOptimizeShareSilent.Text = "Optimize silent";
            this.buttonOptimizeShareSilent.Click += new System.EventHandler(this.buttonOptimizeShareSilent_Click);
            // 
            // gbxPortfolioOptimize
            // 
            this.gbxPortfolioOptimize.Controls.Add(this.buttonOptimizePortfolio_New);
            this.gbxPortfolioOptimize.Controls.Add(this.buttonOptimizePortfolioSilent);
            this.gbxPortfolioOptimize.Controls.Add(this.buttonOptimizePortfolio_1_Overall);
            this.gbxPortfolioOptimize.Controls.Add(this.buttonOptimizeAllPortfolios);
            this.gbxPortfolioOptimize.Location = new System.Drawing.Point(139, 3);
            this.gbxPortfolioOptimize.Name = "gbxPortfolioOptimize";
            this.gbxPortfolioOptimize.Size = new System.Drawing.Size(243, 155);
            this.gbxPortfolioOptimize.TabIndex = 71;
            this.gbxPortfolioOptimize.TabStop = false;
            this.gbxPortfolioOptimize.Text = "Portfolio";
            // 
            // buttonOptimizePortfolio_New
            // 
            this.buttonOptimizePortfolio_New.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonOptimizePortfolio_New.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonOptimizePortfolio_New.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonOptimizePortfolio_New.Location = new System.Drawing.Point(6, 19);
            this.buttonOptimizePortfolio_New.Name = "buttonOptimizePortfolio_New";
            this.buttonOptimizePortfolio_New.Size = new System.Drawing.Size(110, 24);
            this.buttonOptimizePortfolio_New.TabIndex = 65;
            this.buttonOptimizePortfolio_New.Text = "Optimize";
            this.buttonOptimizePortfolio_New.Click += new System.EventHandler(this.buttonOptimizePortfolio_New_Click);
            // 
            // buttonOptimizePortfolioSilent
            // 
            this.buttonOptimizePortfolioSilent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonOptimizePortfolioSilent.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonOptimizePortfolioSilent.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonOptimizePortfolioSilent.Location = new System.Drawing.Point(6, 49);
            this.buttonOptimizePortfolioSilent.Name = "buttonOptimizePortfolioSilent";
            this.buttonOptimizePortfolioSilent.Size = new System.Drawing.Size(110, 24);
            this.buttonOptimizePortfolioSilent.TabIndex = 69;
            this.buttonOptimizePortfolioSilent.Text = "Optimize silent";
            this.buttonOptimizePortfolioSilent.Click += new System.EventHandler(this.buttonOptimizePortfolioSilent_Click);
            // 
            // buttonOptimizePortfolio_1_Overall
            // 
            this.buttonOptimizePortfolio_1_Overall.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonOptimizePortfolio_1_Overall.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonOptimizePortfolio_1_Overall.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonOptimizePortfolio_1_Overall.Location = new System.Drawing.Point(122, 49);
            this.buttonOptimizePortfolio_1_Overall.Name = "buttonOptimizePortfolio_1_Overall";
            this.buttonOptimizePortfolio_1_Overall.Size = new System.Drawing.Size(110, 24);
            this.buttonOptimizePortfolio_1_Overall.TabIndex = 64;
            this.buttonOptimizePortfolio_1_Overall.Text = "Optimize (old)";
            this.buttonOptimizePortfolio_1_Overall.Click += new System.EventHandler(this.buttonOptimizePortfolio_1_Overall_Click);
            // 
            // buttonOptimizeAllPortfolios
            // 
            this.buttonOptimizeAllPortfolios.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonOptimizeAllPortfolios.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonOptimizeAllPortfolios.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonOptimizeAllPortfolios.Location = new System.Drawing.Point(122, 19);
            this.buttonOptimizeAllPortfolios.Name = "buttonOptimizeAllPortfolios";
            this.buttonOptimizeAllPortfolios.Size = new System.Drawing.Size(110, 24);
            this.buttonOptimizeAllPortfolios.TabIndex = 66;
            this.buttonOptimizeAllPortfolios.Text = "Optimize all";
            this.buttonOptimizeAllPortfolios.Click += new System.EventHandler(this.buttonOptimizeAllPortfolios_Click);
            // 
            // tradeViewSystem
            // 
            this.tradeViewSystem.Controls.Add(this.buttonTradeStatistics);
            this.tradeViewSystem.Controls.Add(this.buttonChangeTradeFile);
            this.tradeViewSystem.Controls.Add(this.buttonTradeConfiguration);
            this.tradeViewSystem.Location = new System.Drawing.Point(4, 22);
            this.tradeViewSystem.Name = "tradeViewSystem";
            this.tradeViewSystem.Size = new System.Drawing.Size(1032, 185);
            this.tradeViewSystem.TabIndex = 2;
            this.tradeViewSystem.Text = "Trade System";
            // 
            // buttonTradeStatistics
            // 
            this.buttonTradeStatistics.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonTradeStatistics.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonTradeStatistics.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonTradeStatistics.Location = new System.Drawing.Point(3, 84);
            this.buttonTradeStatistics.Name = "buttonTradeStatistics";
            this.buttonTradeStatistics.Size = new System.Drawing.Size(216, 32);
            this.buttonTradeStatistics.TabIndex = 39;
            this.buttonTradeStatistics.Text = "Trade Statistics";
            this.buttonTradeStatistics.Click += new System.EventHandler(this.buttonTradeStatistics_Click);
            // 
            // buttonChangeTradeFile
            // 
            this.buttonChangeTradeFile.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonChangeTradeFile.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonChangeTradeFile.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonChangeTradeFile.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonChangeTradeFile.Location = new System.Drawing.Point(3, 8);
            this.buttonChangeTradeFile.Name = "buttonChangeTradeFile";
            this.buttonChangeTradeFile.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonChangeTradeFile.Size = new System.Drawing.Size(216, 32);
            this.buttonChangeTradeFile.TabIndex = 37;
            this.buttonChangeTradeFile.Text = "Change Trade System File";
            this.buttonChangeTradeFile.Click += new System.EventHandler(this.buttonChangeTradeFile_Click);
            // 
            // buttonTradeConfiguration
            // 
            this.buttonTradeConfiguration.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonTradeConfiguration.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonTradeConfiguration.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonTradeConfiguration.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonTradeConfiguration.Location = new System.Drawing.Point(3, 46);
            this.buttonTradeConfiguration.Name = "buttonTradeConfiguration";
            this.buttonTradeConfiguration.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonTradeConfiguration.Size = new System.Drawing.Size(216, 32);
            this.buttonTradeConfiguration.TabIndex = 36;
            this.buttonTradeConfiguration.Text = "Create / Change Trade System";
            this.buttonTradeConfiguration.Click += new System.EventHandler(this.buttonTradeConfiguration_Click);
            // 
            // tabPageIntraday
            // 
            this.tabPageIntraday.Controls.Add(this.buttonIntradaySilent);
            this.tabPageIntraday.Controls.Add(this.buttonIntradayTest);
            this.tabPageIntraday.Location = new System.Drawing.Point(4, 22);
            this.tabPageIntraday.Name = "tabPageIntraday";
            this.tabPageIntraday.Size = new System.Drawing.Size(1032, 185);
            this.tabPageIntraday.TabIndex = 5;
            this.tabPageIntraday.Text = "Intraday";
            // 
            // buttonIntradaySilent
            // 
            this.buttonIntradaySilent.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonIntradaySilent.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonIntradaySilent.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonIntradaySilent.Location = new System.Drawing.Point(3, 8);
            this.buttonIntradaySilent.Name = "buttonIntradaySilent";
            this.buttonIntradaySilent.Size = new System.Drawing.Size(152, 24);
            this.buttonIntradaySilent.TabIndex = 5;
            this.buttonIntradaySilent.Text = "Intraday Silent";
            this.buttonIntradaySilent.Click += new System.EventHandler(this.buttonIntradaySilent_Click);
            // 
            // buttonIntradayTest
            // 
            this.buttonIntradayTest.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonIntradayTest.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonIntradayTest.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonIntradayTest.Location = new System.Drawing.Point(3, 38);
            this.buttonIntradayTest.Name = "buttonIntradayTest";
            this.buttonIntradayTest.Size = new System.Drawing.Size(152, 24);
            this.buttonIntradayTest.TabIndex = 4;
            this.buttonIntradayTest.Text = "Intraday";
            this.buttonIntradayTest.Click += new System.EventHandler(this.buttonIntradayTest_Click);
            // 
            // tabPagePrognosis
            // 
            this.tabPagePrognosis.Controls.Add(this.linkLabel1);
            this.tabPagePrognosis.Controls.Add(this.buttonPrognosisShareAdvanced);
            this.tabPagePrognosis.Controls.Add(this.buttonPrognosisPortfolioAdvanced);
            this.tabPagePrognosis.Controls.Add(this.buttonPrognosisPortfolio);
            this.tabPagePrognosis.Controls.Add(this.buttonSharePrognosis);
            this.tabPagePrognosis.Location = new System.Drawing.Point(4, 22);
            this.tabPagePrognosis.Name = "tabPagePrognosis";
            this.tabPagePrognosis.Size = new System.Drawing.Size(1032, 185);
            this.tabPagePrognosis.TabIndex = 3;
            this.tabPagePrognosis.Text = "Prognosis";
            // 
            // linkLabel1
            // 
            this.linkLabel1.Location = new System.Drawing.Point(832, 24);
            this.linkLabel1.Name = "linkLabel1";
            this.linkLabel1.Size = new System.Drawing.Size(56, 24);
            this.linkLabel1.TabIndex = 4;
            this.linkLabel1.TabStop = true;
            this.linkLabel1.Text = "WeB";
            this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
            // 
            // buttonPrognosisShareAdvanced
            // 
            this.buttonPrognosisShareAdvanced.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonPrognosisShareAdvanced.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonPrognosisShareAdvanced.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonPrognosisShareAdvanced.Location = new System.Drawing.Point(3, 8);
            this.buttonPrognosisShareAdvanced.Name = "buttonPrognosisShareAdvanced";
            this.buttonPrognosisShareAdvanced.Size = new System.Drawing.Size(288, 24);
            this.buttonPrognosisShareAdvanced.TabIndex = 3;
            this.buttonPrognosisShareAdvanced.Text = "Share all TradeSystems Prognosis";
            this.buttonPrognosisShareAdvanced.Visible = false;
            this.buttonPrognosisShareAdvanced.Click += new System.EventHandler(this.buttonPrognosisShareAdvanced_Click);
            // 
            // buttonPrognosisPortfolioAdvanced
            // 
            this.buttonPrognosisPortfolioAdvanced.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonPrognosisPortfolioAdvanced.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonPrognosisPortfolioAdvanced.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonPrognosisPortfolioAdvanced.Location = new System.Drawing.Point(3, 38);
            this.buttonPrognosisPortfolioAdvanced.Name = "buttonPrognosisPortfolioAdvanced";
            this.buttonPrognosisPortfolioAdvanced.Size = new System.Drawing.Size(288, 24);
            this.buttonPrognosisPortfolioAdvanced.TabIndex = 2;
            this.buttonPrognosisPortfolioAdvanced.Text = "Portfolio all TradeSystems Prognosis";
            this.buttonPrognosisPortfolioAdvanced.Visible = false;
            this.buttonPrognosisPortfolioAdvanced.Click += new System.EventHandler(this.buttonPrognosisPortfolioAdvanced_Click);
            // 
            // buttonPrognosisPortfolio
            // 
            this.buttonPrognosisPortfolio.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonPrognosisPortfolio.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonPrognosisPortfolio.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonPrognosisPortfolio.Location = new System.Drawing.Point(3, 99);
            this.buttonPrognosisPortfolio.Name = "buttonPrognosisPortfolio";
            this.buttonPrognosisPortfolio.Size = new System.Drawing.Size(288, 24);
            this.buttonPrognosisPortfolio.TabIndex = 1;
            this.buttonPrognosisPortfolio.Text = "Portfolio TradeSystem Indicators";
            this.buttonPrognosisPortfolio.Visible = false;
            this.buttonPrognosisPortfolio.Click += new System.EventHandler(this.buttonPrognosisPortfolio_Click);
            // 
            // buttonSharePrognosis
            // 
            this.buttonSharePrognosis.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(212)))), ((int)(((byte)(208)))), ((int)(((byte)(200)))));
            this.buttonSharePrognosis.Cursor = System.Windows.Forms.Cursors.Default;
            this.buttonSharePrognosis.DialogResult = System.Windows.Forms.DialogResult.None;
            this.buttonSharePrognosis.Font = new System.Drawing.Font("Verdana", 9F);
            this.buttonSharePrognosis.Location = new System.Drawing.Point(3, 69);
            this.buttonSharePrognosis.Name = "buttonSharePrognosis";
            this.buttonSharePrognosis.RightToLeft = System.Windows.Forms.RightToLeft.No;
            this.buttonSharePrognosis.Size = new System.Drawing.Size(288, 24);
            this.buttonSharePrognosis.TabIndex = 0;
            this.buttonSharePrognosis.Text = "Share TradeSystem Indicators";
            this.buttonSharePrognosis.Visible = false;
            this.buttonSharePrognosis.Click += new System.EventHandler(this.buttonPrognosis_Click);
            // 
            // panelListView
            // 
            this.panelListView.BackColor = System.Drawing.SystemColors.ControlDarkDark;
            this.panelListView.Controls.Add(this.gridTrade);
            this.panelListView.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panelListView.Location = new System.Drawing.Point(0, 0);
            this.panelListView.Name = "panelListView";
            this.panelListView.Size = new System.Drawing.Size(1040, 383);
            this.panelListView.TabIndex = 0;
            // 
            // tradeControlSplitContainer
            // 
            this.tradeControlSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tradeControlSplitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
            this.tradeControlSplitContainer.IsSplitterFixed = true;
            this.tradeControlSplitContainer.Location = new System.Drawing.Point(0, 0);
            this.tradeControlSplitContainer.Name = "tradeControlSplitContainer";
            this.tradeControlSplitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
            // 
            // tradeControlSplitContainer.Panel1
            // 
            this.tradeControlSplitContainer.Panel1.Controls.Add(this.panelListView);
            // 
            // tradeControlSplitContainer.Panel2
            // 
            this.tradeControlSplitContainer.Panel2.Controls.Add(this.tabControl1);
            this.tradeControlSplitContainer.Size = new System.Drawing.Size(1040, 576);
            this.tradeControlSplitContainer.SplitterDistance = 383;
            this.tradeControlSplitContainer.SplitterWidth = 5;
            this.tradeControlSplitContainer.TabIndex = 78;
            // 
            // gridTrade
            // 
            this.gridTrade.Dock = System.Windows.Forms.DockStyle.Fill;
            this.gridTrade.GridType = CUtil.GridTypes.Prognosis;
            this.gridTrade.Initialized = false;
            this.gridTrade.Location = new System.Drawing.Point(0, 0);
            this.gridTrade.Multiline = false;
            this.gridTrade.Name = "gridTrade";
            this.gridTrade.ProgramContext = null;
            this.gridTrade.ReadOnly = false;
            this.gridTrade.Size = new System.Drawing.Size(1040, 383);
            this.gridTrade.TabIndex = 0;
            // 
            // TradeControl
            // 
            this.Controls.Add(this.tradeControlSplitContainer);
            this.Name = "TradeControl";
            this.Size = new System.Drawing.Size(1040, 576);
            this.tabControl1.ResumeLayout(false);
            this.tabPageShareSimulation.ResumeLayout(false);
            this.gbxShare.ResumeLayout(false);
            this.gbxPortfolio.ResumeLayout(false);
            this.tabPageOptimize.ResumeLayout(false);
            this.gbxExecutionTime.ResumeLayout(false);
            this.gbxExecutionTime.PerformLayout();
            this.gbxShareOptimize.ResumeLayout(false);
            this.gbxPortfolioOptimize.ResumeLayout(false);
            this.tradeViewSystem.ResumeLayout(false);
            this.tabPageIntraday.ResumeLayout(false);
            this.tabPagePrognosis.ResumeLayout(false);
            this.panelListView.ResumeLayout(false);
            this.tradeControlSplitContainer.Panel1.ResumeLayout(false);
            this.tradeControlSplitContainer.Panel2.ResumeLayout(false);
            this.tradeControlSplitContainer.ResumeLayout(false);
            this.ResumeLayout(false);

		}
		#endregion

		#region public properties


		public IProgramContext ProgramContext
		{
			get
			{
				
				return programContext ;
			}
			set
			{
				
				if(value != null)
				{
					this.gridTrade.ClearGridRows();
					this.programContext = value;
					
					InitializeShareData();
				}


			}
		}
		

		#endregion

		#region event handlers
		
		#region implementations


		#endregion

	
		
		#endregion

		#region implementations 

		protected void buttonTradeConfiguration_Click(object sender, System.EventArgs e)
		{
            try
            {
                MainClass.Instance.DoTradeSystemBuySellSystemChange();
            }
            catch (Exception ex)
            {
                Debug.Assert(false, "Error changing indicators " + ex.Message);

            }
		
		}

	

		protected void buttonChangeTradeFile_Click(object sender, System.EventArgs e)
		{
			MainClass.Instance.DoMenuTradeSystemBuySellChooseFile() ;

		}

		protected void buttonTrade_Click(object sender, System.EventArgs e)
		{
			
			this.gridTrade.CreateGrid(CUtil.GridTypes.Trade, true);

            TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            ts.GridTrade = this.gridTrade;
		}

	


		private bool SimulateShare(TradeWriteModes myTradeMode)
		{
            try
            {
                IDataItem di = this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected;
                if (di == null)
                {
                    System.Windows.Forms.MessageBox.Show("No data item to simulate is selected or available - plese select one ");
                    return false;
                }
                if (di.DataClass.QuoteCollection == null || di.DataClass.QuoteCollection.Count < 1)
                {
                    System.Windows.Forms.MessageBox.Show("No quote data for this share available - hint: try with normal (not intraday) data, e.g. by changing this in Tools-Options-Trade-Intraday Trade ! Occured for:   " + di.DataClass.Name);

                }
                else
                {
                    this.Cursor = System.Windows.Forms.Cursors.WaitCursor;


                    this.gridTrade.CreateGrid(CUtil.GridTypes.Trade, true);

                    this.programContext.Configuration.TerminateAction = false;


                    TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
                    ts.GridTrade = this.gridTrade;
                    if (! ts.SimulationShare(this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected, myTradeMode, true, false, this.gridTrade))
                    {
                        return false;
                    }
                    AfterSingleStep();
                    if (myTradeMode == TradeWriteModes.OnlyTrade)
                    {

                        ts.WriteSingleTradeResult(di, null, true, false);
                    }

                    this.Cursor = System.Windows.Forms.Cursors.Default;
                   
                }
                

                return true;
            }
            catch (Exception ex)
            {
                Debug.Assert(false, "Error in SimulateShare " + ex.Message);
                return false;
            }
           
		}
		protected void buttonSimulateSilent_Click(object sender, System.EventArgs e)
		{
            InitializeSimulations();
			try
			{
                if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                    this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
				TradeWriteModes myTradeMode = TradeWriteModes.EndResultShare;
				SimulateShare(myTradeMode);
			}
			catch(Exception exc)
			{
				Debug.Assert(false,"Error simulating ",exc.Message);
			}

            WriteExecutionTime();
		}
	
		protected void AfterSingleStep()
		{
			
			this.programContext.Configuration.TerminateAction = false;
			//----------------
			this.Cursor = System.Windows.Forms.Cursors.Default;

		}
        private void WriteExecutionTime()
        {
           
            timeExecutionStop = DateTime.Now;
            System.TimeSpan MyDuration = timeExecutionStop - timeExecutionStart;
            this.textBoxExecutionTime.Text = MyDuration.Minutes.ToString() + " min " + MyDuration.Seconds.ToString() + "." + MyDuration.Milliseconds.ToString() ;

            this.Cursor = System.Windows.Forms.Cursors.Default;
            //if (MyDuration.Seconds > 1)
            //{
            //    this.textBoxExecutionTime.Text = MyDuration.Seconds.ToString();
            //    this.labelExecutionTime.Text = "Execution time in SECONDS";
            //}
            //else
            //{
            //    this.labelExecutionTime.Text = "Execution time in MILI - SECONDS";
            //    this.textBoxExecutionTime.Text = MyDuration.Milliseconds.ToString();
            //}
            
        }
        private void SetStartExecutionTime()
        {
            timeExecutionStart = DateTime.Now;
        }
		protected void buttonOptimizeShare_Click(object sender, System.EventArgs e)
		{
            SetStartExecutionTime();
            
            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
			Optimize(true, TradeWriteModes.EndResultShare);

            WriteExecutionTime();


			
		
		}
		private bool Optimize(bool IsDataClass, TradeWriteModes myTradeWriteMode)
		{
            //save trade system - since values are changed during optimization!
            ITradeSystem myts = this.programContext.Trader_Simulation.TradeSimulation.TradeSystem.Copy() as ITradeSystem;

            try
            {
                GetSelectionsFromUI();
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
                this.gridTrade.CreateGrid(CUtil.GridTypes.Optimization, true);
                this.programContext.Configuration.TerminateAction = false;

                TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
                ts.TradeCSVOutputOptions.Reset();
                ts.GridTrade = this.gridTrade;


                if (IsDataClass)
                {
                    IDataItem di = this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected;
                    if (di == null)
                    {
                        System.Windows.Forms.MessageBox.Show("Data item not set for optimization - pls. reset ");
                        return false;
                    }

                    if (di.DataClass.QuoteCollection == null || di.DataClass.QuoteCollection.Count < 1)
                    {
                        System.Windows.Forms.MessageBox.Show("No quote data for this share available - hint: try with normal (not intraday) data, e.g. by changing this in Tools-Options-Trade-Intraday Trade ! Occured for:  " + di.DataClass.Name);

                    }
                    ts.TradeCSVOutputOptions.Share_Optimization_Simulations = true;
                    ts.Optimize(this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected,
                        null, IsDataClass, myTradeWriteMode, this.gridTrade);


                }
                else
                {

                    ts.TradeCSVOutputOptions.Portfolio_Optimization_OnlyPortfolio = true;
                    ts.Optimize(null, this.programContext.TradeEconomy.Portfolio_Simulation,
                        IsDataClass, myTradeWriteMode, this.gridTrade);

                    

                }
                AfterSingleStep();

            }
            catch (Exception ex)
            {
                Debug.Assert(false, "Error in optimizing portfolio : " + ex.Message);
                this.Cursor = System.Windows.Forms.Cursors.Default;
                return false;

            }
            this.Cursor = System.Windows.Forms.Cursors.Default;
            this.programContext.Trader_Simulation.TradeSimulation.TradeSystem = myts ;

            return true;

		}

        public void OptimizePortfolio_1_Overall()
        {
            //save trade system - since values are changed during optimization!
            ITradeSystem myts = this.programContext.Trader_Simulation.TradeSimulation.TradeSystem.Copy();


            this.gridTrade.CreateGrid(CUtil.GridTypes.Optimization, true);

            System.Diagnostics.Debug.Assert(this.programContext.Trader_Simulation.Portfolio_Simulation != null);

            if (this.programContext.Trader_Simulation.Portfolio_Simulation == null)
                return;

            if (this.programContext.Trader_Simulation.Portfolio_Simulation.DataItems.Count < 1)
            {
                System.Windows.Forms.MessageBox.Show("No data items available in portfolio ");
                return;
            }
            this.programContext.Configuration.TerminateAction = false;
            this.gridTrade.ClearGridRows();

            //------------------------------------
            TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            ts.GridTrade = this.gridTrade;
            ts.OptimizePortfolio_1_Overall(this.programContext.TradeEconomy.Portfolio_Simulation, this.gridTrade);
            //------------------------------------
            AfterSingleStep();

            
            WriteExecutionTime();
            this.programContext.Trader_Simulation.TradeSimulation.TradeSystem = myts;

        }

        protected void buttonOptimizePortfolio_1_Overall_Click(object sender, System.EventArgs e)
		{
            InitializeSimulations();
			this.Cursor =  System.Windows.Forms.Cursors.WaitCursor;
			OptimizePortfolio_1_Overall();
		
			this.Cursor =  System.Windows.Forms.Cursors.Default;
            WriteExecutionTime();
		}

		#endregion

		private void PreInitializeForPrognosis()
		{
            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
			//MainClass.Instance.DoTradeSystemBuySell();
			
			this.gridTrade.ClearGridRows();
			//DateTime myDate = new DateTime();
			if(this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected.DataClass.QuoteCollection.Count <= 0)
			{
                DataClass.DeSerialize(this.programContext.Trader_Simulation.Portfolio_Selected.DataItem_Selected.DataClass, this.programContext.Configuration.IntradayModus);
			}
			
		}
		protected void buttonPrognosis_Click(object sender, System.EventArgs e)
		{
			this.gridTrade.CreateGrid(CUtil.GridTypes.Prognosis, true);
			
			PreInitializeForPrognosis();
			
			
            ((TradeSimulation)this.programContext.Trader_Simulation.TradeSimulation).PrognosisShare(this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected,
                this.programContext.Configuration.Dates.DateMax, 0);

		}
		private void buttonPrognosisShareAdvanced_Click(object sender, System.EventArgs e)
		{
			this.gridTrade.CreateGrid(CUtil.GridTypes.Prognosis, true);
			
			PreInitializeForPrognosis();

            double prog = ((TradeSimulation)this.programContext.Trader_Simulation.TradeSimulation).PrognosisShareAdvanced
                (this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected, this.programContext.Configuration.Dates.DateMax);
				

		}


	

	

		private void buttonstopFlag_Click(object sender, System.EventArgs e)
		{
		
		}

		protected void buttonPrognosisPortfolio_Click(object sender, System.EventArgs e)
		{
			this.gridTrade.CreateGrid(CUtil.GridTypes.Prognosis, true);
			PreInitializeForPrognosis();

			
			this.programContext.Trader_Simulation.TradeSimulation.PrognosisPortfolio(this.programContext.TradeEconomy.Portfolio_Simulation, 
                this.programContext.Configuration.Dates.DateMax, 0);
		
		}
		private void buttonPrognosisPortfolioAdvanced_Click(object sender, System.EventArgs e)
		{
			this.gridTrade.CreateGrid(CUtil.GridTypes.Prognosis, true);
            this.programContext.Trader_Simulation.TradeSimulation.PrognosisPortfolioAdvanced(this.programContext.TradeEconomy.Portfolio_Simulation);
		

		}

		private void textBoxEndDate_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			
		}

		private void buttonResetPortfolio_Click(object sender, System.EventArgs e)
		{

            IPortfolio port = this.programContext.Trader_Simulation.Portfolio_Simulation;
			port.ResetTradings();
			MainClass.Instance.RefreshChartView();
			
		}

	

		private void buttonReset_Click(object sender, System.EventArgs e)
		{
			this.gridTrade.ClearGridRows();
            TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            ts.GridTrade = this.gridTrade;
            TradeStepFactory.Reset_Share_ForSimulation(this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected,
                        ts.TradeSystem, false, TradeStepFactory.ProgramContext.Configuration.TradeMoneyType, false);



			
		}

	

		protected void buttonSingleStep_Click(object sender, System.EventArgs e)
		{
            try
            {
                InitializeSimulations();

                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;

                TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
                ts.GridTrade = this.gridTrade;

                if(this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected == null)
                {
                    WriteExecutionTime();
                    System.Windows.Forms.MessageBox.Show("NO data item selected ");
                    return;
                }
                ITradeStep myTradeStep = this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected.TradeStep;

                myTradeStep.TradeWriteMode = TradeWriteModes.EachTradeStep;

                if (!myTradeStep.TradeSimulationInitiaded)
                {
                    if (!TradeStepFactory.FirstInit_TradeStep(this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected, ts.TradeSystem))
                    {
                        WriteExecutionTime();
                        return;
                    }
                }
                
                TradeStepFactory.StepShareIncreaseDate(this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected, ts.TradeSystem, false, this.gridTrade, false);
                WriteExecutionTime();
            }
            catch (Exception ex)
            {
                Debug.Assert(false, "Error in single trade " + ex.Message);
            }

		
		}
        private void  InitializeSimulations()
        {
            this.SetStartExecutionTime();
            if (this.gridTrade.GridType != GridTypes.Trade || !this.gridTrade.Initialized)
            {
                this.gridTrade.CreateGrid(CUtil.GridTypes.Trade, true);
            }
            GetSelectionsFromUI();
        
        }
		private void buttonSingleStepPortfolio_Click(object sender, System.EventArgs e)
		{

            InitializeSimulations();


            GetSelectionsFromUI();

			//this.gridTrade.Items.Clear();
			this.Cursor = System.Windows.Forms.Cursors.WaitCursor;

          
            TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            ts.GridTrade = this.gridTrade;
            if (this.programContext.TradeEconomy.Portfolio_Simulation.DataItems.Count < 1)
            {
                System.Windows.Forms.MessageBox.Show("No data items available in portfolio " + this.programContext.TradeEconomy.Portfolio_Simulation.Name);
                this.Cursor = System.Windows.Forms.Cursors.Default;
                return;
            }
            TradeStepFactory.StepPortfolio(this.programContext.TradeEconomy.Portfolio_Simulation, this.gridTrade, false);
			
			//looses focus !
			//update the tree view - every time ??
			//MainClass.Instance.RefreshTree();

            this.programContext.Trader_Simulation.Portfolio_Simulation.Serialize();

			AfterSingleStep();
			this.Cursor = System.Windows.Forms.Cursors.Default;

            this.WriteExecutionTime();
		}
		private void SimulatePortfolio_2_EachShare(CUtil.TradeWriteModes myTradeMode)
		{
            try
            {
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
                
                InitializeSimulations();
                

                
                if (this.ProgramContext.Configuration.TerminateAction)
                    this.ProgramContext.Configuration.TerminateAction = false;

                this.gridTrade.CreateGrid(CUtil.GridTypes.Trade, true);


                this.programContext.Configuration.TerminateAction = false;


                TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
                ts.GridTrade = this.gridTrade;
                ts.SimulationPortfolio_Individual(this.programContext.TradeEconomy.Portfolio_Simulation, myTradeMode
                    , this.gridTrade, false);
                AfterSingleStep();

                this.programContext.Trader_Simulation.Portfolio_Simulation.Serialize();
                //simulation result in csv file
                //ts.Write_OptimizationResults(false, false);
               
                    
                this.Cursor = System.Windows.Forms.Cursors.Default;
                WriteExecutionTime();
            }
            catch (Exception ex)
            {
                Debug.Assert(false, "Error simulating portfolio: " + ex.Message);
            }

		}
        private void buttonSimulatePortfolio_1_EachShare_Click(object sender, System.EventArgs e)
		{
            InitializeSimulations();
            
            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
			CUtil.TradeWriteModes myTradeMode = TradeWriteModes.OnlyTrade;
            SimulatePortfolio_2_EachShare(myTradeMode);


            WriteExecutionTime();

		}
       
		private void buttonSimulationPortfolio1Reset_Click(object sender, System.EventArgs e)
		{
            
            InitializeSimulations();
           
           

			this.gridTrade.ClearGridRows();

            TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            ts.GridTrade = this.gridTrade;
            TradeStepFactory.Reset_Portfolio_TradeStep(this.programContext.TradeEconomy.Portfolio_Simulation, ts.TradeSystem, 
                TradeWriteModes.Nothing,false, this.programContext.Configuration.TradeMoneyType, false);

            WriteExecutionTime();
		}

		private void buttonSimulateShare_Click(object sender, System.EventArgs e)
		{
            InitializeSimulations();

            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
			TradeWriteModes myTradeMode = TradeWriteModes.OnlyTrade;
			
			SimulateShare(myTradeMode);
            
            
            WriteExecutionTime();
		}

		private void buttonTradeEvents_Click(object sender, System.EventArgs e)
		{
			ShowTradeEventsInList();
			//MainClass.Instance.ShowTradeEventsInList();

		
		}
		public void ShowTradeEventsInList()
		{
			this.gridTrade.CreateGrid(CUtil.GridTypes.TradeEvent, true);


            TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            ts.GridTrade = this.gridTrade;
            this.gridTrade.WriteTradeEvents(this.programContext.TradeEconomy.Portfolio_Simulation.TradeStepPortfolio.TradeEvents);

			
		}

//		private void buttonTransactionEvents_Click(object sender, System.EventArgs e)
//		{
//			
//			this.programContext.Configuration.ShowTradeEventsOnChart = true;
//			MainClass.Instance.DoMenuChartTradeEvents();
//
//		}

		private void buttonSimulatePortfolioSilent_Click(object sender, System.EventArgs e)
		{
            InitializeSimulations();
            //this.SetStartExecutionTime();
			CUtil.TradeWriteModes myTradeMode = TradeWriteModes.EndResultShare;
            SimulatePortfolio_2_EachShare(myTradeMode);
            WriteExecutionTime();
		
		}

        private void buttonSimulatePortfolio_1_Overall_Click(object sender, System.EventArgs e)
		{
            this.SetStartExecutionTime();
            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
			

			SimulatePortfolio_1_Overall(TradeWriteModes.OnlyTrade);

            WriteExecutionTime();
		}
        private void GetSelectionsFromUI()
        {
            if (this.programContext.Configuration.ProgramMode == ProgramModes.Realtime)
            {
                this.programContext.Trader_Simulation.Portfolio_Simulation = this.programContext.TradeEconomy.Portfolio_Selected;
            }
            IDataItem di = this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected;
            if (di == null)
            {
                this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected = this.programContext.Trader_Simulation.Portfolio_Simulation.DataItems[0];
                //di = this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected;
            }


        }
		private void SimulatePortfolio_1_Overall(TradeWriteModes myTradeMode)
		{
            try
            {
                InitializeSimulations();
                this.Cursor = System.Windows.Forms.Cursors.WaitCursor;


                
                if (this.ProgramContext.Configuration.TerminateAction)
                    this.ProgramContext.Configuration.TerminateAction = false;

                this.gridTrade.CreateGrid(CUtil.GridTypes.Trade, true);

                TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
                ts.GridTrade = this.gridTrade;
                //ts.SimulationPortfolioew(TradeWriteModes.EachTradeStep);
                if(ts.SimulationPortfolio_PerDate(this.programContext.TradeEconomy.Portfolio_Simulation, myTradeMode, false, this.gridTrade))
                    WriteExecutionTime();

                this.Cursor = System.Windows.Forms.Cursors.Default;
               
            }
            catch (Exception ex)
            {
                Debug.Assert(false, "Error in simulation " + ex.Message);

            }
		}

		

		private void buttonSimulatePortfolio_1_OverallSilent_Click(object sender, System.EventArgs e)
		{
            InitializeSimulations();
            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
			SimulatePortfolio_1_Overall(TradeWriteModes.EndResultShare);
            WriteExecutionTime();
		}

		private void buttonAllPortfoliosSimulate_Click(object sender, System.EventArgs e)
		{
            InitializeSimulations();
			this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
			
			this.gridTrade.CreateGrid(CUtil.GridTypes.Trade, true);
            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
            TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            ts.GridTrade = this.gridTrade;
           
            ts.SimulationPortfolio_PerDate(this.programContext.TradeEconomy.Portfolio_Simulation, TradeWriteModes.EndResultShare, false, this.gridTrade);
			
           

			this.Cursor = System.Windows.Forms.Cursors.Default;
            WriteExecutionTime();
		}

		private void buttonOptimizeAllPortfolios_Click(object sender, System.EventArgs e)
		{
            this.SetStartExecutionTime();
            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
            TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            ts.GridTrade = this.gridTrade;
            for (int i = 0; i < this.programContext.Trader_Simulation.Portfolios.Items.Count; i++)
			{
                this.programContext.Trader_Simulation.Portfolio_Simulation = this.programContext.Trader_Simulation.Portfolios[i];
				

                ts.SimulationPortfolio_PerDate(this.programContext.TradeEconomy.Portfolio_Simulation, TradeWriteModes.EndResultShare, false, this.gridTrade);
                Optimize(false, TradeWriteModes.EndResultPortfolio);
			}
			//ts.Write_OptimizationResults(false,true);

            WriteExecutionTime();
		}

		private void gridTrade_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}

		private void buttonStatisticsPortfolio_Click(object sender, System.EventArgs e)
		{
			try
			{
                this.programContext.TradeEconomy.Portfolio_Simulation.TradeStepPortfolio.CreateListPerYearCollection();
				
				TradeStatisticType ts = TradeStatisticType.All;
                CapitalReSources.TradeStatistics tradeS = new CapitalReSources.TradeStatistics(this.programContext.Trader_Simulation.Portfolio_Simulation, ts);
				tradeS.ShowDialog();
			}
			catch(Exception exc)
			{
				Debug.Assert(false,"Error showing trade statistics ! ", exc.Message);
			}
		
		}
		private void buttonStatisticsShare_Click(object sender, System.EventArgs e)
		{
			try
			{
                this.programContext.TradeEconomy.Portfolio_Simulation.TradeStepPortfolio.CreateListPerYearCollection();
				
				TradeStatisticType ts = TradeStatisticType.All;
				CapitalReSources.TradeStatistics tradeS = new CapitalReSources.TradeStatistics(this.programContext.Trader_Simulation.Portfolio_Simulation, ts);
				tradeS.ShowDialog();
			}
			catch(Exception exc)
			{
				Debug.Assert(false,"Error showing trade statistics ! ", exc.Message);
			}
		}

		
		private void FillListPerYearOld(bool onlyRelativePerformance)
		{
            ITradeStep myTradeStep = this.programContext.TradeEconomy.Portfolio_Simulation.TradeStepPortfolio;

            myTradeStep.CreateListPerYearCollection();
			
			this.gridTrade.CreateGrid(CUtil.GridTypes.Performance, true);
			

	
			//2. fill the columns

            for (int yearIndex = 0; yearIndex < myTradeStep.PerformancePerYearCollection.Count; yearIndex++)
			{
				int startYear = yearIndex + 3;
                string strYear = myTradeStep.PerformancePerYearCollection.Keys[yearIndex];
				//Grid TODO
//				if(gridPerformance.Columns.Count >= startYear)
//				{
//					gridPerformance.AddColumn(strYear);
//					
//				}
//				else
//				{
//					gridPerformance.Columns[yearIndex + 3].Text = strYear;
//				}
		
			}


			//3. fill the list share by share
			for(int i = 0; i < this.programContext.Trader_Simulation.Portfolio_Simulation.DataItems.Count; i++)
			{
				//4. share name
				//Grid TODO
//				gridPerformance.ClearSubItemCollection();
//				gridPerformance[ListViewYearEnum.Share] = this.programContext.Trader_Simulation.Portfolio_Simulation.DataItems[i].DataClass.Name;

                myTradeStep = this.programContext.Trader_Simulation.Portfolio_Simulation.DataItems[i].TradeStep;


                for (int j = 0; j < myTradeStep.PerformancePerYearCollection.Count; j++)
				{

                    string strYear = myTradeStep.PerformancePerYearCollection.Keys[j].ToString();
					//5. fill item for each year
					if(onlyRelativePerformance)
					{
                        if (myTradeStep.PerformanceRelativePerYearCollection != null &&
                            myTradeStep.PerformanceRelativePerYearCollection[strYear] != null)
						{
							//GridTODO
							//gridPerformance[strYear] = this.programContext.Trader_Simulation.Portfolio_Simulation.DataItems[i].DataClass.PerformanceRelativePerYearCollection[strYear].ToString() ;
				
					
						}
					}
					else
					{
                        if (myTradeStep.PerformancePerYearCollection != null &&
                            myTradeStep.PerformancePerYearCollection[strYear] != null)
						{
							//Grid TODO
							//gridPerformance[strYear] = this.programContext.Trader_Simulation.Portfolio_Simulation.DataItems[i].DataClass.PerformancePerYearCollection[strYear].ToString() ;
						}
					}
				}
				//Grid TODO
				//gridPerformance.AddNewItem();
			
				
			}
					

				
				

			

			//--------------
			//6. add portfolio 


			this.gridTrade.ClearGridRows();
			////Grid TODO
//			gridPerformance.ClearSubItemCollection();
//			gridPerformance[ListViewYearEnum.Share] = "Portfolio: " + this.programContext.Trader_Simulation.Portfolio_Simulation.Name;
//			
            myTradeStep = this.programContext.TradeEconomy.Portfolio_Simulation.TradeStepPortfolio;

            for (int yearIndex = 0; yearIndex < myTradeStep.PerformancePerYearCollection.Count; yearIndex++)
			{
                string strYear = myTradeStep.PerformancePerYearCollection.Keys[yearIndex];
				
				//int yearIndex = Convert.ToInt32(strYear);
				
				if(onlyRelativePerformance )
				{
					//Grid TODO
//					if(this.programContext.Trader_Simulation.Portfolio_Simulation.PerformanceRelativePerYearCollection[strYear] != null)
//						gridPerformance[strYear] = this.programContext.Trader_Simulation.Portfolio_Simulation.PerformanceRelativePerYearCollection[strYear].ToString() ;
				}
				else
				{
                    if (myTradeStep.PerformancePerYearCollection[strYear] != null)
					{
						//Grid TODO
						//gridPerformance[strYear] = this.programContext.Trader_Simulation.Portfolio_Simulation.PerformancePerYearCollection[strYear].ToString() + "(" + this.programContext.Trader_Simulation.Portfolio_Simulation.PerformanceRelativePerYearCollection[strYear].ToString() + ")";
					}
					else
					{
						//Grid TODO
						//gridPerformance[strYear] = this.programContext.Trader_Simulation.Portfolio_Simulation.PerformancePerYearCollection[strYear].ToString() ;
					
					}
				}
					
				
			}
			//Grid TODO
			//gridPerformance.AddNewItem();

			//for(int i = 0; i < this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected
			//this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected.DataClass.TradeStep.PerformancePerYearCollection();
			
			
			

		}
	
	

		private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
		{
			System.Diagnostics.Process.Start("www.logisel.de/CapitalReSources.htm");
			
		}

		private void buttonIntradayTest_Click(object sender, System.EventArgs e)
		{
			TradeWriteModes myTradeMode = TradeWriteModes.EachTradeStep;
			IntradaySimulation(myTradeMode);

			

		
		}
		private void IntradaySimulation(TradeWriteModes myTradeMode)
		{
			//

			this.programContext.Configuration.TerminateAction = false;
			this.programContext.Configuration.IntradayModus = true;
			
			this.gridTrade.CreateGrid(CUtil.GridTypes.Trade, true);

			IDataClass dc = this.programContext.Trader_Simulation.Portfolio_Simulation.DataItem_Selected.DataClass;
	
			TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            ts.GridTrade = this.gridTrade;

            ts.SimulationShare(this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected, myTradeMode, true, false, this.gridTrade);
		}

		private void buttonIntradaySilent_Click(object sender, System.EventArgs e)
		{
			TradeWriteModes myTradeMode = TradeWriteModes.OnlyTrade;
			
            IntradaySimulation(myTradeMode);

		}

		private void buttonTradeStatistics_Click(object sender, System.EventArgs e)
		{

            TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            ts.GridTrade = this.gridTrade;
            //TradeStatistics
			
			//CapitalReSources.TradeStatistics tradeS = new CapitalReSources.TradeStatistics(ts.TradeStep);
			//tradeS.ShowDialog();

			//todo
			//this.TradeStep

		}
        private void buttonOptimizePortfolio_New_Click(object sender, System.EventArgs e)
        {
            this.SetStartExecutionTime();
            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
            Optimize(false, TradeWriteModes.EndResultShare);

            WriteExecutionTime();
        }
        private void buttonOptimizePortfolioSilent_Click(object sender, EventArgs e)
        {
            this.SetStartExecutionTime();
            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();

            TradeSimulation ts = this.programContext.Trader_Simulation.TradeSimulation as TradeSimulation;
            Optimize(false, TradeWriteModes.EndResultPortfolio);

            WriteExecutionTime();

        }

        private void buttonOptimizeShareSilent_Click(object sender, EventArgs e)
        {
            SetStartExecutionTime();

            if (this.programContext.Trader_Simulation.TradeSimulation.TradeSystem == null)
                this.programContext.Trader_Simulation.TradeSimulation.SetDefaultTradeSystem();
            Optimize(true, TradeWriteModes.Nothing);

            WriteExecutionTime();
            System.Windows.Forms.MessageBox.Show("Optmization done");


        }

      
		


	}
}